package titt.io.socket.in;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import titt.io.IOFactory;

public class StaticInputStream implements TITTInputStream {

	private final TITTInputStream in;
	
	public StaticInputStream(byte[] in) throws Exception {
		this(in, 0);
	}

	public StaticInputStream(byte[] in, int off) throws Exception {
		this(in, off, in.length-off);
	}
	
	public StaticInputStream(byte[] in, int off, int len) throws Exception {
		this.in = IOFactory.createInputStream(new ByteArrayInputStream(in, off, len));
	}

	
	@Override
	public InputStream asStream() {
		return in.asStream();
	}

	@Override
	public void close() throws Exception {
		in.close();
	}

	@Override
	public void read(byte[] buffer) throws Exception {
		in.read(buffer);
	}

	@Override
	public byte[] readLine() throws Exception {
		return in.readLine();
	}

	@Override
	public byte[] readFully() throws Exception {
		return in.readFully();
	}
}
